Skip to content

refactor(core): drop redundant viewport-mercator-project dependency - #2881

Merged
lzxue merged 1 commit into
masterfrom
refactor/core-drop-unused-viewport-mercator-dep
Jul 21, 2026
Merged

refactor(core): drop redundant viewport-mercator-project dependency#2881
lzxue merged 1 commit into
masterfrom
refactor/core-drop-unused-viewport-mercator-dep

Conversation

@lzxue

@lzxue lzxue commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

What

packages/core/package.json declared both viewport-mercator-project and @types/viewport-mercator-project as direct deps, but packages/core/src never actually imports the package — the only mention is a documentation URL comment in CoordinateSystemService.ts:124, which is not a code usage.

This PR removes the redundant declarations from core.

The real runtime consumer is packages/maps/src/lib/web-mercator-viewport.ts (value import WebMercatorViewport from 'viewport-mercator-project', exercised by all 8 map adapters). packages/maps/src/earth/Viewport.ts uses an import type for an interface-only field that is never instantiated and whose projectFlat is never called from earth/map.ts — also covered by the maps-scope declaration, not core's.

The maps package therefore retains its own declaration and the workspace dependency graph is essentially unchanged — pnpm-lock.yaml only drops the importer-of-record lines for core (-6 lines).

Why now (modernization investigation)

A prior turn looked into modernizing viewport-mercator-project to the latest npm tag. Findings:

  • The npm-latest tag (7.0.4) is deprecated by vis.gl and is literally module.exports = require('@math.gl/web-mercator') under the hood.
  • The underlying @math.gl/web-mercator@4.1.0 uses a different projection convention — no 2^zoom scaling on projectFlat / center, and substantially different matrix conventions.
  • Runtime comparison at the same {width,height,longitude,latitude,zoom,pitch,bearing} options showed a 2^zoom factor divergence in projectFlat / center, which would break L7's rendering pipeline downstream (layers / shaders / CameraService).
  • v6.2.3 itself is not deprecated — only the npm-latest wrapper is. So staying on v6.2.3 is fine.

A full migration to the latest is therefore out of scope for this PR. The only uncontroversially-safe cleanup is removing core's dead direct declaration — which is what this commit does.

A future "vendor v6 source into the repo" PR (preserve v6 behavior exactly, remove the external dep completely) is feasible but requires its own risk review and visual regression pass, and is not in scope here.

Changes

  • packages/core/package.json — removed viewport-mercator-project (^6.2.1) from dependencies, @types/viewport-mercator-project (^6.1.0) from devDependencies.
  • pnpm-lock.yaml — drops 6 lines (the importer-of-record entry for core; the package itself stays because maps still uses it transitively).

packages/maps/package.json is intentionally untouched — maps is the legitimate consumer.

Validation

  • Core tsc --noEmit -p packages/core/tsconfig.json: clean.
  • Maps tsc --noEmit -p packages/maps/tsconfig.json: only pre-existing baseline noise (.glsl module resolution + unrelated camera.ts undefined checks); no new errors from this change.
  • prettier (CI's check-format.sh glob **/*.{ts,tsx,js,jsx,json,md,css,less}): packages/core/package.json clean. (Lockfile yaml is outside CI's prettier glob.)

Risk

Zero runtime risk — core has no actual code usage of the package. Maps and the rest of the rendering pipeline are untouched.

`packages/core/package.json` declared both `viewport-mercator-project` and
`@types/viewport-mercator-project` as direct deps, but `packages/core/src`
never actually imports the package. The only mention is a documentation
URL comment in `CoordinateSystemService.ts:124` which is not a code usage.

The real runtime consumer is `packages/maps/src/lib/web-mercator-viewport.ts`
(value `import WebMercatorViewport from 'viewport-mercator-project'`,
exercised by all 8 map adapters). `packages/maps/src/earth/Viewport.ts`
uses a `import type` for an interface-only field, also covered by the
maps-scope declaration. The maps package therefore retains its own
declaration and the workspace dependency graph is unchanged — pnpm-lock
only drops the importer-of-record lines for core (-6 lines).

背景/Investigation note
-----------------------
A prior turn looked into modernizing `viewport-mercator-project` to the
latest npm tag. That tag (7.0.4) is **deprecated** by vis.gl and is
literally `module.exports = require('@math.gl/web-mercator')` — the
underlying `@math.gl/web-mercator@4.1.0` uses a different projection
convention (no `2^zoom` scaling on `projectFlat`/`center`, different
matrix conventions). Runtime comparison at the same options showed a
`2^zoom` factor divergence between v6.2.3 and v4.1.0, which would break
L7's rendering pipeline downstream (layers/shaders/CameraService).

So a full migration to the latest is **out of scope** for this PR. v6.2.3
itself is *not* deprecated (only the npm-latest wrapper is). The only
uncontroversially-safe cleanup is removing core's dead direct
declaration, which is what this commit does. A future "vendor v6 source
into the repo" PR (preserve v6 behavior exactly, remove external dep)
is feasible but requires its own risk review.
@changeset-bot

changeset-bot Bot commented Jul 19, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: c2495f4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the unused dependency viewport-mercator-project and its corresponding TypeScript types @types/viewport-mercator-project from the packages/core package, updating the lockfile accordingly. There are no review comments, and I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@lzxue
lzxue merged commit 6310b52 into master Jul 21, 2026
8 checks passed
@lzxue
lzxue deleted the refactor/core-drop-unused-viewport-mercator-dep branch July 21, 2026 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant